home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10449 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: nntp.coast.net!torn!nott!cunews!wabakimi!abelo
  2. From: abelo@chat.carleton.ca (Andrew Belo)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: floats in borland C++ 4.5
  5. Date: 17 Mar 1996 23:31:36 GMT
  6. Organization: Carleton University, Ottawa, Canada
  7. Message-ID: <4ii7co$18j@bertrand.ccs.carleton.ca>
  8. References: <4if2ec$scg@bertrand.ccs.carleton.ca> <827086760snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: wabakimi.carleton.ca
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Lawrence Kirby (fred@genesis.demon.co.uk) wrote:
  13. > In article <4if2ec$scg@bertrand.ccs.carleton.ca>
  14. >            abelo@chat.carleton.ca "Andrew Belo" writes:
  15.  
  16. > >
  17. > >void bubblesort( double *dblarray, int numberOfElements)
  18. > >
  19. > >{
  20. > >        int top, search, temp; 
  21. > >
  22. > >        for( top = 0; top < numberOfElements -1; top++)
  23. > >                for(search = top +1; search < numberOfElements; search++)
  24. > >                        if(dblarray[search] > dblarray[top])
  25. > >                        {
  26. > >                                temp = dblarray[search];
  27. > >                                dblarray[search] = dblarray[top];
  28. > >                                dblarray[top] = temp; 
  29. > >                        }
  30. > >}
  31.  
  32. > Firstly this isn't a bubble sort (e.g. bubble sort always compares and swaps
  33. > adjacent elements), it is an exchange sort. Do you have any reason not to
  34. > use the standard library qsort() function - it is likely to be much more
  35. > efficient.
  36.  
  37. It is for an assignment!  I know that it isn't a true bubble sort we were
  38. told to use this algorithm and to name the function this.
  39.  
  40. I have however found that if I go to the target expert and make it a
  41. floating point program it works fine!
  42.  
  43.        *******
  44.      ***********     Andrew Belo
  45.     *************    Carleton University
  46.    ***************   abelo@chat.carleton.ca
  47.     *************
  48.      ***********     
  49.       |       |
  50.      9| 0   0 |P
  51.       |   @   |
  52.       |   Q --|----Afros in the house
  53.       \_mmmmm_/
  54.          mmm
  55.